$OpenBSD: patch-format_cpp,v 1.2 2014/04/29 08:55:52 zhuk Exp $
Add OpenBSD support, make sure that newfs_ext2fs is checked first.
--- format.cpp.orig	Mon Aug 22 17:26:09 2011
+++ format.cpp	Mon Feb  6 20:16:21 2012
@@ -799,22 +799,28 @@ void UFSFilesystem::exec()
 
 
 /* static */ QString Ext2Filesystem::newfs = QString();
+/* static */ bool Ext2Filesystem::native_mke2fs = true;
 
 Ext2Filesystem::Ext2Filesystem(QObject *parent) :
 	FloppyAction(parent)
 {
 	DEBUGSETUP;
 	runtimeCheck();
-	theProcessName=QLatin1String( "mke2fs" );
+	theProcessName=newfs;
 	setObjectName( QLatin1String("Ext2Filesystem" ));
 }
 
 /* static */ bool Ext2Filesystem::runtimeCheck()
 {
 	DEBUGSETUP;
 
-	newfs = findExecutable(QLatin1String( "mke2fs" ));
-
+	newfs = findExecutable( "newfs_ext2fs" );
+	if (!newfs.isEmpty()) {
+		native_mke2fs = false;
+		return true;
+	}
+	native_mke2fs = true;
+	newfs = findExecutable( "mke2fs" );
 	return !newfs.isEmpty();
 }
 
@@ -861,8 +867,14 @@ void Ext2Filesystem::exec()
 
 	*p << newfs;
 	*p << "-q";
-	if (doVerify) *p << QLatin1String( "-c" ) ;
-	if (doLabel) *p << QLatin1String( "-L" ) << label ;
+	if (native_mke2fs) {
+		if (doVerify) *p << QLatin1String( "-c" ) ;
+		if (doLabel) *p << QLatin1String( "-L" ) << label ;
+	} else {
+		// newfs_ext2fs, as found on OpenBSD
+		if (doVerify) *p << QLatin1String( "-N" ) ;
+		if (doLabel) *p << QLatin1String( "-v" ) << label ;
+	}
 
 	*p << deviceName ;
 
